package toannm;

import java.util.ArrayList;
import java.util.Arrays;

import main.pak.R;
import main.pak.StableArrayAdapter;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

public class ChoiceQuestion extends Activity {
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_choice_question);
		
		final ListView lstView = (ListView) findViewById(R.id.lstView);
        // Get String 
//        String[] values = new String[] {"ONe", "Two"};

        // Get String from Resources
        Resources res = getResources();
        String[] values = res.getStringArray(R.array.answer_array);

        final ArrayList<String> list = new ArrayList<String>();
        list.addAll(Arrays.asList(values));

        final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list);
        lstView.setAdapter(adapter);

        lstView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                final String item = (String) parent.getItemAtPosition(position);
                Toast alerter = Toast.makeText(getApplicationContext(), item, Toast.LENGTH_SHORT);
                alerter.setDuration(10);
                alerter.show();
            }
        });
	}
}
